﻿@page "/Po/BuyReturnDetail/BatchEdit"
@using nERP.ViewModel.Po.BuyReturnDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
    <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
    <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
        <BootstrapInput @bind-Value="@Model.LinkedVM.Seq" />
        <Select @bind-Value="@Model.LinkedVM.BuyReturnId" Items="AllBuyReturns" Id="gc0955fade71d472d9245dd549bfddc4d" />
        <Select @bind-Value="@Model.LinkedVM.BuyInWarehouseDetailId" Items="AllBuyInWarehouseDetails" Id="ge6de3c8bb8a641d482f22b1400e478ef" />
        <Select @bind-Value="@Model.LinkedVM.BuyId" Items="AllBuys" Id="g739e580237bb45c8a231c98ccd1406b2" />
        <Select @bind-Value="@Model.LinkedVM.BuyDatailId" Items="AllBuyDatails" Id="gd5f02f5ee4a540098092e9013c704efb" />
        <Select @bind-Value="@Model.LinkedVM.GoodsId" Items="AllGoodss" Id="g285a3fb40c1a4a448e083f3038fdcd6d" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsName" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsSpec" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsUnit" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.ReturnNumber" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.UnitPrice" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.TotalPrice" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.DiscountPrice" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.TaxRate" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.TaxUnitPrice" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.TaxPrice" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.TotalTaxPrice" />
        <BootstrapInput @bind-Value="@Model.LinkedVM.Remark" />
    </Row>

    <div class="modal-footer table-modal-footer">
        <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]" />
        <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]" />
    </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private BuyReturnDetailBatchVM Model = new BuyReturnDetailBatchVM();
    private ValidateForm vform { get; set; }

    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/Po/BuyReturnDetail/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }


    public void OnClose()
    {
        CloseDialog();
    }

    private List<SelectedItem> AllBuyReturns = new List<SelectedItem>();
    private List<SelectedItem> AllBuyInWarehouseDetails = new List<SelectedItem>();
    private List<SelectedItem> AllBuys = new List<SelectedItem>();
    private List<SelectedItem> AllBuyDatails = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {


        AllBuyReturns = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetBuyReturns");
        AllBuyReturns.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllBuyInWarehouseDetails = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetBuyInWarehouseDetails");
        AllBuyInWarehouseDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllBuys = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetBuys");
        AllBuys.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllBuyDatails = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetBuyDetails");
        AllBuyDatails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });

        await base.OnInitializedAsync();
    }
}
